package com.tgq.demo.mapper;

import com.tgq.demo.entity.Menu;
import com.tgq.demo.entity.Role;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 陶国庆
 * @since 2023-02-10
 */
public interface RoleMapper extends BaseMapper<Role> {

    @Select("select id from sys_role where flag=#{flag}")
    Integer selectByFlag(@Param("flag") String flag);

    @Select("SELECT sys_menu.id,sys_menu.description,sys_menu.icon,sys_menu.`name`,sys_menu.path,sys_menu.pid FROM sys_role \n" +
            "\t\t\t\tJOIN sys_role_menu on  sys_role_menu.role_id = sys_role.id\n" +
            "\t\t\t\tJOIN sys_menu  ON sys_menu.id = sys_role_menu.menu_id\n" +
            "\t\t\t\tWHERE sys_role.flag = #{flag}")
    List<Menu> getroleMenus(@Param("flag")String flag);

}
